package it.win4buy.presentations
{
    import flash.events.IEventDispatcher;

    import it.win4buy.events.NavigationEvent;
    import it.win4buy.events.PlayEvent;
    import it.win4buy.events.UtilityEvent;
    import it.win4buy.models.ApplicationModel;
    import it.win4buy.utility.ApplicationConstants;
    import it.win4buy.utility.LoggerUtilty;

    import mx.resources.ResourceManager;

    /**
     *
     *	autore:
     *  pierangelo.mancusi@gmail.com
     *
     */

    public class PlayViewPM
    {



        //-------------------------------------------
        //
        // Injected properties
        //
        //-------------------------------------------

        [Dispatcher]
        public var dispatcher:IEventDispatcher;

        [Inject]
        public var applicationModel:ApplicationModel;

        [Inject]
        public var log:LoggerUtilty;

        //-------------------------------------------
        //
        // Private Properties
        //
        //-------------------------------------------

        /**
         *Current State
         */
        private var _currentViewState:String="";

        /**
         * Set the "enable" and "visible" property
         */
        private var _btConfirmVisible:Boolean;


        /**
         *Set thye visible and enabled properties
         */
        private var _btCancelVisible:Boolean;


        /**
         *Message showed in the alert
         */
        private var _alertMessage:String="";




        //-------------------------------------------
        //
        // Getters / Setters
        //
        //-------------------------------------------

        public function get alertMessage():String
        {
            return _alertMessage;
        }

        public function set alertMessage(value:String):void
        {
            _alertMessage=value;
        }

        [Bindable]
        /**
         *Set thye visible and enabled properties
         */
        public function get btCancelVisible():Boolean
        {
            return _btCancelVisible;
        }

        public function set btCancelVisible(value:Boolean):void
        {
            _btCancelVisible=value;
        }

        [Bindable]
        /**
         * Set the "enable" and "visible" property
         */
        public function get btConfirmVisible():Boolean
        {
            return _btConfirmVisible;
        }

        public function set btConfirmVisible(value:Boolean):void
        {
            _btConfirmVisible=value;
        }

        [Bindable]
        /**
         * Current State.<br>
         *
         */
        public function get currentViewState():String
        {
            return _currentViewState;
        }

        /**
         * @private
         */
        public function set currentViewState(value:String):void
        {
            _currentViewState=value;
        }

        //-------------------------------------------
        //
        // Constructor
        //
        //-------------------------------------------

        public function PlayViewPM()
        {

        }

        //-------------------------------------------
        //
        // Mediator Handlers
        //
        //-------------------------------------------

        [EventHandler(event="UtilityEvent.STARTUP_PLAY_MODE", priority="990")]
        public function startupPlayMode(event:UtilityEvent):void
        {

            //setup view
            log.logToConsole(this, "startupPlayMode.");


            currentViewState=ApplicationConstants.VIEW_PLAY_ALERT;
            setLoadingAlert();

        }

        [EventHandler(event="NavigationEvent.VIEW_PLAY_ALERT", priority="990")]
        public function setAlertState(event:NavigationEvent):void
        {


            currentViewState=ApplicationConstants.VIEW_PLAY_ALERT;

        }

        //-------------------------------------------
        //
        // Public Methods
        //
        //-------------------------------------------
        /**
         * Used by the View to startup all functionality
         *
         */
        public function startupPlayView():void
        {
            dispatcher.dispatchEvent(new UtilityEvent(UtilityEvent.CREATION_COMPLETE_PLAYVIEW, null, true));
        }

        //-------------------------------------------
        //
        // Private Methods
        //
        //-------------------------------------------

        private function setLoadingAlert():void
        {


            dispatcher.dispatchEvent(new PlayEvent(PlayEvent.ALERT_STARTUP, null, true));

        }


    }
}